<?php

class SER
{
	public static function slugify( $text )
	{
		// replace all non letters or digits by -
	    $text = preg_replace('/\W+/', '_', $text);
	 
	    // trim and lowercase
	    $text = trim($text, '_');
	 
	    return $text;
	}
	
	public static function deSlugify( $text )
	{
		if (is_string($text))
		{
			return str_replace('_', ' ', $text);
		}
		else if (is_array($text))
		{
			foreach ($text as &$item)
			{
				$item = self::deSlugify($item);
			}
		}
		else
		{
			return null;
		}
			
	}
}

?>